<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:f="http://xmlns.jcp.org/jsf/core"
      xmlns:p="http://primefaces.org/ui">

    <ui:composition template="/template.xhtml">
        <ui:define name="body">
            <h:form id="ProfissaoFormacaoListForm">
                <p:breadCrumb>
                    <p:menuitem value="Home" url="#" />
                    <p:menuitem value="Cadastro" url="#" />
                    <p:menuitem value="Profissão / Formação" url="#" />
                </p:breadCrumb>
                <p:panel>
                    <p:dataTable id="datalist" 
                                 emptyMessage="Nenhum registro localizado"
                                 widgetVar="FiltroGlobal"
                                 value="#{profissaoFormacaoController.items}" 
                                 var="item"
                                 selectionMode="single" 
                                 selection="#{profissaoFormacaoController.selected}"
                                 paginator="true"
                                 rowKey="#{item.id}"
                                 rows="10"
                                 paginatorPosition="bottom"
                                 rowsPerPageTemplate="10,20,30,40,50" >
                        
                        <p:ajax event="rowSelect"   update="createButton editButton editButtonTop deleteButton deleteButtonTop"/>
                        <p:ajax event="rowUnselect" update="createButton editButton editButtonTop deleteButton deleteButtonTop"/>
                        
                        <f:facet name="header">
                            <p:outputPanel>
                                <p:inputText id="globalFilter" style="width:200px;" placeholder=""/>
                                <p:commandButton value="Filtrar" id="withIcon" onclick="PF('FiltroGlobal').filter()" icon="ui-icon-search" />
                                <p:commandButton id="toggler" type="button" value="Colunas" style="float:right" icon="ui-icon-calculator" rendered="false" />
                                <p:columnToggler datasource="datalist" trigger="toggler" />                                

                                <p:commandButton id="createButtonTop" icon="ui-icon-plus"   value="#{bundle.Create}" actionListener="#{profissaoFormacaoController.prepareCreate}" update=":ProfissaoFormacaoCreateForm" oncomplete="PF('ProfissaoFormacaoCreateDialog').show()"/>
                                <p:commandButton id="editButtonTop"   icon="ui-icon-pencil" value="#{bundle.Edit}" update=":ProfissaoFormacaoEditForm" oncomplete="PF('ProfissaoFormacaoEditDialog').show()" disabled="#{empty profissaoFormacaoController.selected}"/>
                                <p:commandButton id="deleteButtonTop" icon="ui-icon-trash" value="#{bundle.Delete}" actionListener="#{profissaoFormacaoController.destroy}" update=":growl,datalist" disabled="#{empty profissaoFormacaoController.selected}">
                                    <p:confirm header="Confirmação" message="Confirma a exclusão?" icon="ui-icon-alert"/>
                                </p:commandButton>
                                <p:confirmDialog global="true">
                                    <p:commandButton value="Sim" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check"/>
                                    <p:commandButton value="Não" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close"/>
                                </p:confirmDialog>                                
                            </p:outputPanel>
                        </f:facet>                        

                        <p:column filterBy="#{item.id}" filterMatchMode="contains" filterStyle="display:none;">
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListProfissaoFormacaoTitle_id}"/>
                            </f:facet>
                            <h:outputText value="#{item.id}"/>
                        </p:column>
                        <p:column filterBy="#{item.descricao}" filterMatchMode="contains" filterStyle="display:none;">
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListProfissaoFormacaoTitle_descricao}"/>
                            </f:facet>
                            <h:outputText value="#{item.descricao}"/>
                        </p:column>
                        <p:column filterBy="#{item.profissao.toString().equals('S') ? 'S': 'N'}" filterMatchMode="equals" style="width:280px;">  
                            <f:facet name="header">
                                <h:outputText value="Tipo"/>
                            </f:facet>
                            <f:facet name="filter">
                                <p:selectOneButton onchange="PF('FiltroGlobal').filter()">
                                    <f:selectItem itemLabel="Todos" itemValue="" />
                                    <f:selectItem itemLabel="Profissão" itemValue="S" />
                                    <f:selectItem itemLabel="Formação" itemValue="N" />
                                </p:selectOneButton>
                            </f:facet>
                            <h:outputText value="#{item.profissao.toString().equals('S') ? 'Profissão': 'Formação'}"/>
                        </p:column>
                        <f:facet name="footer">
                            <p:commandButton id="createButton" icon="ui-icon-plus"   value="#{bundle.Create}" actionListener="#{profissaoFormacaoController.prepareCreate}" update=":ProfissaoFormacaoCreateForm" oncomplete="PF('ProfissaoFormacaoCreateDialog').show()"/>
                            <p:commandButton id="editButton"   icon="ui-icon-pencil" value="#{bundle.Edit}" update=":ProfissaoFormacaoEditForm" oncomplete="PF('ProfissaoFormacaoEditDialog').show()" disabled="#{empty profissaoFormacaoController.selected}"/>
                            <p:commandButton id="deleteButton" icon="ui-icon-trash" value="#{bundle.Delete}" actionListener="#{profissaoFormacaoController.destroy}" update=":growl,datalist" disabled="#{empty profissaoFormacaoController.selected}">
                                <p:confirm header="Confirmação" message="Confirma a exclusão?" icon="ui-icon-alert"/>
                            </p:commandButton>
                            <p:confirmDialog global="true">
                                <p:commandButton value="Sim" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check"/>
                                <p:commandButton value="Não" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close"/>
                            </p:confirmDialog>
                        </f:facet>                       
                    </p:dataTable>
                </p:panel>
            </h:form>

            <ui:include src="Create.xhtml"/>
            <ui:include src="Edit.xhtml"/>
            
        </ui:define>
    </ui:composition>

</html>
